using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Enemy_SkeletonAnimationFinishTriggers : MonoBehaviour
{
    private Enemy_Skeleton enemy => GetComponentInParent<Enemy_Skeleton>();

    // 动画播放完毕事件
    private void AnimationFinishTrigger()
    {
        enemy.AnimationFinishTrigger();
    }

    // 动画攻击事件
    private void AttackTrigger()
    {
        // 获取攻击圆圈内所有碰撞体
        Collider2D[] colliders = Physics2D.OverlapCircleAll(enemy.attackCheck.position, enemy.attackCheckRadius);

        foreach (var hit in colliders)
        {
            // 判断玩家
            if (hit.GetComponent<Player>() != null)
            {
                PlayerStats _target = hit.GetComponent<PlayerStats>();//获取玩家状态
                enemy.stats.DoDamage(_target);//对玩家造成伤害
            }
        }

    }


    private void OpenCounterWindow() => enemy.OpenCounterAttackWindow();// 开启攻击动画预警
    private void CloseCounterWindow() => enemy.CloseCounterAttackWindow();// 关闭攻击动画预警

}
